package technion.gc.web;

import org.apache.log4j.Logger;
import technion.gc.api.implementation.interfaces.IGraphCrawler;

public class Main {

	
	/*
	 * TODO: summing up the current problems
	 * need to add logs, remove prints, 
	 */

	private static Logger log = Logger.getLogger(Main.class);
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if (args.length < 1) {
			log.fatal("Missing domain argument");
			return;
		}
		
		if (args.length < 2) {
			log.fatal("Missing depth argument");
			return;
		}
		WebGraph graph = new WebGraph();
		WebGraphNode root = new WebGraphNode(args[0]);
		try {
			int maxDepth = Integer.parseInt(args[1]);
			root.setMaximumDepth(maxDepth);
		}
		catch (Exception e) {
			log.fatal("depth argument was of a wrong format");
			return;
		}
		if (args.length == 3) {
			root.setDomainConsistent(true);
			root.setDomain(args[2]);
		}
		
		//ALWAYS
		root.setDepth(1);
		root.setLog(log);
		graph.setRoot(root);
		WebGraphCrawlerFactory gcFactory = new WebGraphCrawlerFactory();
		IGraphCrawler gc = gcFactory.createGraphCrawler();
		gc.traverseGraph(graph);
	}

}
